package com.my.zidingyikongjian.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.my.zidingyikongjian.R;

public class FourCanvasActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_four_canvas);

        initView();
    }

    private void initView() {
        findViewById(R.id.btn_translate_canvas).setOnClickListener(this);
        findViewById(R.id.btn_rotate_canvas).setOnClickListener(this);
        findViewById(R.id.btn_scale_canvas).setOnClickListener(this);
        findViewById(R.id.btn_skew_canvas).setOnClickListener(this);
        findViewById(R.id.btn_clip_canvas).setOnClickListener(this);
        findViewById(R.id.btn_save_and_restore_canvas).setOnClickListener(this);
        findViewById(R.id.btn_save_and_restore_two_canvas).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_translate_canvas: // 平移canvas
                goIntnet("1");
                break;
            case R.id.btn_rotate_canvas: // 旋转canvas
                goIntnet("2");
                break;
            case R.id.btn_scale_canvas: // 缩放canvas
                goIntnet("3");
                break;
            case R.id.btn_skew_canvas: // 扭曲canvas
                goIntnet("4");
                break;
            case R.id.btn_clip_canvas: // 裁剪canvas
                goIntnet("5");
                break;
            case R.id.btn_save_and_restore_canvas: // 保存与恢复
                goIntnet("6");
                break;
            case R.id.btn_save_and_restore_two_canvas: // 保存与恢复
                goIntnet("7");
                break;
        }
    }

    private void goIntnet(String flag) {
        Intent intent = new Intent(FourCanvasActivity.this, FourActivity.class);
        intent.putExtra("four", flag);
        startActivity(intent);
    }
}
